/*
 * @Author: szx
 * @Date: 2022-01-13 13:15:37
 * @LastEditTime: 2022-01-13 13:24:16
 * @Description: 
 * @FilePath: \leetcode\700-799\747\747.js
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
 var dominantIndex = function(nums) {
    let index = -1;
    let max =  Number.MIN_VALUE
    for(let i =0;i<nums.length;i++){
        if(nums[i]>max){
            max = nums[i];
            index = i;
        }
    }
    for(let i =0;i<nums.length;i++){
        if(max != nums[i] && max<nums[i]*2) return -1;
    }
    return index;
};